home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg2.cab / style_mapping_html32.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-06  |  20.5 KB  |  491 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.    $RCSfile: style_mapping_html32.xsl,v $
  5.  
  6.    $Revision: 1.3 $
  7.  
  8.    last change: $Author: rt $ $Date: 2004/07/05 09:05:55 $
  9.  
  10.    The Contents of this file are made available subject to the terms of
  11.    either of the following licenses
  12.  
  13.           - GNU Lesser General Public License Version 2.1
  14.           - Sun Industry Standards Source License Version 1.1
  15.  
  16.    Sun Microsystems Inc., October, 2000
  17.  
  18.    GNU Lesser General Public License Version 2.1
  19.    =============================================
  20.    Copyright 2000 by Sun Microsystems, Inc.
  21.    901 San Antonio Road, Palo Alto, CA 94303, USA
  22.  
  23.    This library is free software; you can redistribute it and/or
  24.    modify it under the terms of the GNU Lesser General Public
  25.    License version 2.1, as published by the Free Software Foundation.
  26.  
  27.    This library is distributed in the hope that it will be useful,
  28.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  30.    Lesser General Public License for more details.
  31.  
  32.    You should have received a copy of the GNU Lesser General Public
  33.    License along with this library; if not, write to the Free Software
  34.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  35.    MA  02111-1307  USA
  36.  
  37.  
  38.    Sun Industry Standards Source License Version 1.1
  39.    =================================================
  40.    The contents of this file are subject to the Sun Industry Standards
  41.    Source License Version 1.1 (the "License"); You may not use this file
  42.    except in compliance with the License. You may obtain a copy of the
  43.    License at http://www.openoffice.org/license.html.
  44.  
  45.    Software provided under this License is provided on an "AS IS" basis,
  46.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  47.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  48.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  49.    See the License for the specific provisions governing your rights and
  50.    obligations concerning the Software.
  51.  
  52.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  53.  
  54.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  55.  
  56.    All Rights Reserved.
  57.  
  58.    Contributor(s): _______________________________________
  59.  
  60. -->
  61. <!--
  62.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  63. -->
  64. <xsl:stylesheet version="1.0"
  65.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  66.                 xmlns:office="http://openoffice.org/2000/office"
  67.                 xmlns:style="http://openoffice.org/2000/style"
  68.                 xmlns:text="http://openoffice.org/2000/text"
  69.                 xmlns:table="http://openoffice.org/2000/table"
  70.                 xmlns:draw="http://openoffice.org/2000/drawing"
  71.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  72.                 xmlns:xlink="http://www.w3.org/1999/xlink"
  73.                 xmlns:number="http://openoffice.org/2000/datastyle"
  74.                 xmlns:svg="http://www.w3.org/2000/svg"
  75.                 xmlns:chart="http://openoffice.org/2000/chart"
  76.                 xmlns:dr3d="http://openoffice.org/2000/dr3d"
  77.                 xmlns:math="http://www.w3.org/1998/Math/MathML"
  78.                 xmlns:form="http://openoffice.org/2000/form"
  79.                 xmlns:script="http://openoffice.org/2000/script"
  80.                 xmlns:dc="http://purl.org/dc/elements/1.1/"
  81.                 xmlns:meta="http://openoffice.org/2000/meta"
  82.                 xmlns:config="http://openoffice.org/2001/config"
  83.                 xmlns:help="http://openoffice.org/2000/help"
  84.                 exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help">
  85.  
  86.  
  87.     <xsl:template name="write-style-properties">
  88.         <xsl:param name="style:properties" />
  89.  
  90.         <!--+++++ PALM 3.2 SUBSET AND WAP PROPERTIES  +++++-->
  91.         <xsl:for-each select="$style:properties/@*">
  92.             <xsl:choose>
  93.                 <!--*** FORMAT ATTRIBUTES ***-->
  94.  
  95.                 <!-- Italic -->
  96.                 <xsl:when test='name()="fo:font-style"'>
  97.                     <xsl:if test="contains(., 'italic') or contains(., 'oblique')">
  98.                         <xsl:text>italic, </xsl:text>
  99.                     </xsl:if>
  100.                 </xsl:when>
  101.  
  102.                 <!-- Boldface -->
  103.                 <xsl:when test='name()="fo:font-weight"'>
  104.                     <xsl:if test="contains(., 'bold') or contains(., 'bolder')">
  105.                         <xsl:text>bold, </xsl:text>
  106.                     </xsl:if>
  107.                 </xsl:when>
  108.  
  109.                 <!-- Underline -->
  110.                 <xsl:when test='name()="style:text-underline"'>
  111.                     <xsl:text>underline, </xsl:text>
  112.                 </xsl:when>
  113.  
  114.                 <!-- Alignment -->
  115.                 <xsl:when test='name()="fo:text-align"'>
  116.                      <xsl:choose>
  117.                         <xsl:when test="contains(., 'start')">
  118.                             <xsl:text>align:left, </xsl:text>
  119.                         </xsl:when>
  120.                         <xsl:when test="contains(., 'end')">
  121.                             <xsl:text>align:right, </xsl:text>
  122.                         </xsl:when>
  123.                         <xsl:when test="contains(., 'center')">
  124.                             <xsl:text>align:center, </xsl:text>
  125.                         </xsl:when>
  126.                      </xsl:choose>
  127.                 </xsl:when>
  128.  
  129.                 <!-- strikethrough -->
  130.                 <xsl:when test='name()="style:text-crossing-out"'>
  131.                     <xsl:text>strike, </xsl:text>
  132.                 </xsl:when>
  133.  
  134.                 <!-- Font - size (Palm: emulator transformed sizes to available set (e.g. 30 to (probably) 9)-->
  135.                 <xsl:when test='name()="fo:font-size"'>
  136.                     <xsl:text>size:</xsl:text><xsl:value-of select="." /><xsl:text>:size, </xsl:text>
  137.                 </xsl:when>
  138.  
  139.                 <!-- Font - Color (PALM: but mostly only 2 available)
  140.                     black (#000000)
  141.                     gray (#808080)(rendered as dark gray)
  142.                     silver (#C0C0C0)(rendered as light gray)
  143.                     white (#FFFFFF)-->
  144.                 <xsl:when test='name()="fo:color"'>
  145.                     <xsl:choose>
  146.                         <xsl:when test="contains(. , '#FFFFFF') or contains(. , '#ffffff') or contains(. , 'white') or contains(. , 'WHITE')">
  147.                             <xsl:text>color:#FFFFFF, </xsl:text>
  148.                         </xsl:when>
  149.                         <xsl:otherwise>
  150.                             <xsl:text>color:#000000, </xsl:text>
  151.                         </xsl:otherwise>
  152.                     </xsl:choose>
  153.                 </xsl:when>
  154.  
  155.                 <!--*** TABLE ATTRIBUTES ***-->
  156.                 <xsl:when test='name()="fo:font-size"'>
  157.                     <xsl:text>size:</xsl:text><xsl:value-of select="." /><xsl:text>:size, </xsl:text>
  158.                 </xsl:when>
  159.                 <xsl:when test='name()="style:column-width"'>
  160.                     <xsl:text>width:</xsl:text>
  161.                     <xsl:choose>
  162.                         <!-- changing the distance measure: inch to in -->
  163.                         <xsl:when test="contains(., 'inch')">
  164.                             <xsl:value-of select="substring-before(.,'ch')" />
  165.                         </xsl:when>
  166.                         <xsl:otherwise>
  167.                             <xsl:value-of select="." />
  168.                         </xsl:otherwise>
  169.                     </xsl:choose>
  170.                     <xsl:text>:width, </xsl:text>
  171.                 </xsl:when>
  172.                 <xsl:when test='name()="style:row-height"'>
  173.                     <xsl:text>height:</xsl:text>
  174.                     <xsl:choose>
  175.                         <!-- changing the distance measure: inch to in -->
  176.                         <xsl:when test="contains(., 'inch')">
  177.                             <xsl:value-of select="substring-before(.,'ch')" />
  178.                         </xsl:when>
  179.                         <xsl:otherwise>
  180.                             <xsl:value-of select="." />
  181.                         </xsl:otherwise>
  182.                     </xsl:choose>
  183.                     <xsl:text>:height; </xsl:text>
  184.                 </xsl:when>
  185.                 <xsl:when test='name()="style:width"'> <!--earlier fo:width-->
  186.                     <xsl:text>width:</xsl:text>
  187.                     <xsl:choose>
  188.                         <!-- changing the distance measure: inch to in -->
  189.                         <xsl:when test="contains(., 'inch')">
  190.                             <xsl:value-of select="substring-before(.,'ch')" />
  191.                         </xsl:when>
  192.                         <xsl:otherwise>
  193.                             <xsl:value-of select="." />
  194.                         </xsl:otherwise>
  195.                     </xsl:choose>
  196.                     <xsl:text>:width; </xsl:text>
  197.                 </xsl:when>
  198.             </xsl:choose>
  199.         </xsl:for-each>
  200.     </xsl:template>
  201.  
  202.  
  203.  
  204.     <!-- ********************************* -->
  205.     <!-- *** creating table attributes *** -->
  206.     <!-- ********************************* -->
  207.  
  208.     <!-- table data (td) and table header (th) attributes -->
  209.     <xsl:template name="create-attribute-ALIGN">
  210.         <xsl:param name="styleProperties" />
  211.  
  212.         <xsl:if test="contains($styleProperties, 'align')">
  213.             <xsl:attribute name="align">
  214.                  <xsl:choose>
  215.                     <xsl:when test="contains($styleProperties, 'align:left')">
  216.                         <xsl:text>left</xsl:text>
  217.                     </xsl:when>
  218.                     <xsl:when test="contains($styleProperties, 'align:right')">
  219.                         <xsl:text>right</xsl:text>
  220.                     </xsl:when>
  221.                     <xsl:otherwise>
  222.                         <xsl:text>center</xsl:text>
  223.                     </xsl:otherwise>
  224.                  </xsl:choose>
  225.             </xsl:attribute>
  226.         </xsl:if>
  227.     </xsl:template>
  228.  
  229.  
  230.     <!-- ********************************* -->
  231.     <!-- *** creating List attributes  *** -->
  232.     <!-- ********************************* -->
  233. <!--
  234.     <xsl:template name="create-list-attributes">
  235.         <xsl:param name="styleProperties" />
  236.  
  237.  
  238. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  239. 2 be implemented
  240. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  241.  
  242.  
  243.     </xsl:template>
  244. -->
  245.  
  246.     <!-- ************************************************ -->
  247.     <!-- *** creating nested format tags (PALM & WML) *** -->
  248.     <!-- ************************************************ -->
  249.  
  250.     <!-- Italic -->
  251.     <xsl:template name="create-nested-format-tags">
  252.         <xsl:param name="globalData" />
  253.         <xsl:param name="styleProperties" />
  254.         <xsl:choose>
  255.             <xsl:when test="contains($styleProperties, 'italic')">
  256.                 <xsl:element namespace="{$namespace}" name="i">
  257.                     <xsl:call-template name="bold">
  258.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  259.                         <xsl:with-param name="globalData" select="$globalData" />
  260.                     </xsl:call-template>
  261.                 </xsl:element>
  262.             </xsl:when>
  263.             <xsl:otherwise>
  264.                 <xsl:call-template name="bold">
  265.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  266.                     <xsl:with-param name="globalData" select="$globalData" />
  267.                 </xsl:call-template>
  268.             </xsl:otherwise>
  269.         </xsl:choose>
  270.     </xsl:template>
  271.  
  272.  
  273.     <!-- Bold -->
  274.     <xsl:template name="bold">
  275.         <xsl:param name="globalData" />
  276.         <xsl:param name="styleProperties" />
  277.  
  278.         <xsl:choose>
  279.             <xsl:when test="contains($styleProperties, 'bold')">
  280.                 <xsl:element namespace="{$namespace}" name="b">
  281.                     <xsl:call-template name="underline">
  282.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  283.                         <xsl:with-param name="globalData" select="$globalData" />
  284.                     </xsl:call-template>
  285.                 </xsl:element>
  286.             </xsl:when>
  287.             <xsl:otherwise>
  288.                 <xsl:call-template name="underline">
  289.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  290.                     <xsl:with-param name="globalData" select="$globalData" />
  291.                 </xsl:call-template>
  292.             </xsl:otherwise>
  293.         </xsl:choose>
  294.     </xsl:template>
  295.  
  296.  
  297.     <!-- Underline : last format attribute, which is also used from WML - WML ends here! -->
  298.     <xsl:template name="underline">
  299.         <xsl:param name="globalData" />
  300.         <xsl:param name="styleProperties" />
  301.  
  302.         <xsl:choose>
  303.             <xsl:when test="$outputType = 'PALM'">
  304.                 <xsl:choose>
  305.                     <xsl:when test="contains($styleProperties, 'underline')">
  306.                         <xsl:element namespace="{$namespace}" name="u">
  307.                             <xsl:call-template name="strikethrough">
  308.                                 <xsl:with-param name="styleProperties" select="$styleProperties" />
  309.                                 <xsl:with-param name="globalData" select="$globalData" />
  310.                             </xsl:call-template>
  311.                         </xsl:element>
  312.                     </xsl:when>
  313.                     <xsl:otherwise>
  314.                         <xsl:call-template name="strikethrough">
  315.                             <xsl:with-param name="styleProperties" select="$styleProperties" />
  316.                             <xsl:with-param name="globalData" select="$globalData" />
  317.                         </xsl:call-template>
  318.                     </xsl:otherwise>
  319.                 </xsl:choose>
  320.             </xsl:when>
  321.             <xsl:otherwise>
  322.                 <xsl:choose>
  323.                     <xsl:when test="contains($styleProperties, 'underline')">
  324.                         <xsl:element namespace="{$namespace}" name="u">
  325.                             <xsl:apply-templates>
  326.                                 <xsl:with-param name="globalData" select="$globalData" />
  327.                             </xsl:apply-templates>
  328.                         </xsl:element>
  329.                     </xsl:when>
  330.                     <xsl:otherwise>
  331.                         <xsl:apply-templates>
  332.                             <xsl:with-param name="globalData" select="$globalData" />
  333.                         </xsl:apply-templates>
  334.                     </xsl:otherwise>
  335.                 </xsl:choose>
  336.             </xsl:otherwise>
  337.         </xsl:choose>
  338.     </xsl:template>
  339.  
  340.  
  341.     <!-- strikethrough -->
  342.     <xsl:template name="strikethrough">
  343.         <xsl:param name="globalData" />
  344.         <xsl:param name="styleProperties" />
  345.  
  346.         <xsl:choose>
  347.             <xsl:when test="contains($styleProperties, 'strike')">
  348.                 <xsl:element namespace="{$namespace}" name="strike">
  349.                     <xsl:call-template name="align">
  350.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  351.                         <xsl:with-param name="globalData" select="$globalData" />
  352.                     </xsl:call-template>
  353.                 </xsl:element>
  354.             </xsl:when>
  355.             <xsl:otherwise>
  356.                 <xsl:call-template name="align">
  357.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  358.                     <xsl:with-param name="globalData" select="$globalData" />
  359.                 </xsl:call-template>
  360.             </xsl:otherwise>
  361.         </xsl:choose>
  362.     </xsl:template>
  363.  
  364.  
  365.     <!-- Alignment -->
  366.     <xsl:template name="align">
  367.         <xsl:param name="globalData" />
  368.         <xsl:param name="styleProperties" />
  369.  
  370.         <xsl:choose>
  371.             <xsl:when test="contains($styleProperties, 'align')">
  372.                 <xsl:element namespace="{$namespace}" name="div">
  373.                     <xsl:attribute name="style">
  374.                          <xsl:choose>
  375.                             <xsl:when test="contains($styleProperties, 'align:left')">
  376.                                 <xsl:text>text-align:left;</xsl:text>
  377.                             </xsl:when>
  378.                             <xsl:when test="contains($styleProperties, 'align:right')">
  379.                                 <xsl:text>text-align:right;</xsl:text>
  380.                             </xsl:when>
  381.                             <xsl:otherwise>
  382.                                 <xsl:text>text-align:center;</xsl:text>
  383.                             </xsl:otherwise>
  384.                          </xsl:choose>
  385.                     </xsl:attribute>
  386.                     <xsl:call-template name="font_combined">
  387.                         <xsl:with-param name="styleProperties" select="$styleProperties" />
  388.                         <xsl:with-param name="globalData" select="$globalData" />
  389.                     </xsl:call-template>
  390.                 </xsl:element>
  391.             </xsl:when>
  392.             <xsl:otherwise>
  393.                 <xsl:call-template name="font_combined">
  394.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  395.                     <xsl:with-param name="globalData" select="$globalData" />
  396.                 </xsl:call-template>
  397.             </xsl:otherwise>
  398.         </xsl:choose>
  399.     </xsl:template>
  400.  
  401.  
  402.     <!-- Both size and Color for font -->
  403.     <xsl:template name="font_combined">
  404.         <xsl:param name="globalData" />
  405.         <xsl:param name="styleProperties" />
  406.  
  407.         <xsl:choose>
  408.             <xsl:when test="contains($styleProperties, 'color') and contains($styleProperties, 'size')">
  409.                 <xsl:element namespace="{$namespace}" name="font">
  410.  
  411.                     <xsl:attribute name="color">
  412.                          <xsl:choose>
  413.                             <xsl:when test="contains($styleProperties, 'color:#000000')">
  414.                                 <xsl:text>#000000</xsl:text>
  415.                             </xsl:when>
  416.                             <xsl:otherwise>
  417.                                 <xsl:text>#FFFFFF</xsl:text>
  418.                             </xsl:otherwise>
  419.                          </xsl:choose>
  420.                     </xsl:attribute>
  421.  
  422.                     <xsl:attribute name="size">
  423.                         <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')" />
  424.                     </xsl:attribute>
  425.  
  426.                     <!-- get the embedded content -->
  427.                     <xsl:apply-templates>
  428.                         <xsl:with-param name="globalData" select="$globalData" />
  429.                     </xsl:apply-templates>
  430.                 </xsl:element>
  431.             </xsl:when>
  432.             <xsl:otherwise>
  433.                 <xsl:call-template name="font_simple">
  434.                     <xsl:with-param name="styleProperties" select="$styleProperties" />
  435.                     <xsl:with-param name="globalData" select="$globalData" />
  436.                 </xsl:call-template>
  437.             </xsl:otherwise>
  438.         </xsl:choose>
  439.     </xsl:template>
  440.  
  441.  
  442.     <!-- size or Color for font -->
  443.     <xsl:template name="font_simple">
  444.         <xsl:param name="globalData" />
  445.         <xsl:param name="styleProperties" />
  446.  
  447.         <xsl:choose>
  448.             <xsl:when test="contains($styleProperties, 'color')">
  449.                 <xsl:element namespace="{$namespace}" name="font">
  450.                     <xsl:attribute name="color">
  451.                          <xsl:choose>
  452.                             <xsl:when test="contains($styleProperties, 'color:#000000')">
  453.                                 <xsl:text>#000000</xsl:text>
  454.                             </xsl:when>
  455.                             <xsl:otherwise>
  456.                                 <xsl:text>#FFFFFF</xsl:text>
  457.                             </xsl:otherwise>
  458.                          </xsl:choose>
  459.                     </xsl:attribute>
  460.  
  461.                     <!-- get the embedded content -->
  462.                     <xsl:apply-templates>
  463.                         <xsl:with-param name="globalData" select="$globalData" />
  464.                     </xsl:apply-templates>
  465.                 </xsl:element>
  466.             </xsl:when>
  467.  
  468.             <xsl:when test="contains($styleProperties, 'size')">
  469.                 <xsl:element namespace="{$namespace}" name="font">
  470.                     <xsl:attribute name="size">
  471.                         <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')" />
  472.                     </xsl:attribute>
  473.  
  474.                     <!-- get the embedded content -->
  475.                     <xsl:apply-templates>
  476.                         <xsl:with-param name="globalData" select="$globalData" />
  477.                     </xsl:apply-templates>
  478.                 </xsl:element>
  479.             </xsl:when>
  480.  
  481.             <xsl:otherwise>
  482.                 <!-- get the embedded content -->
  483.                 <xsl:apply-templates>
  484.                     <xsl:with-param name="globalData" select="$globalData" />
  485.                 </xsl:apply-templates>
  486.             </xsl:otherwise>
  487.         </xsl:choose>
  488.     </xsl:template>
  489.  
  490. </xsl:stylesheet>
  491.